package net.demo.demo2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServer {
    public static void main(String[] args) throws IOException {
        //创建服务端的对象
        ServerSocket ss = new ServerSocket(10001);
        //等待数据
        Socket accept = ss.accept();
        //获取数据字节流难获取中文,且读写速度慢
//        InputStream is = accept.getInputStream();
        //使用高速读写缓冲流,一层一层嵌套进去
        BufferedReader bfd=new BufferedReader(new InputStreamReader(accept.getInputStream()));
        //显示数据
        int b;
        while ((b=bfd.read())!=-1){
            System.out.print((char) b);
        }

        ss.close();
    }
}
